package setup

import (
	"games.com/server/internal/pkg/config"
	"github.com/spf13/viper"
	"log"
)

func InitConfig() (*config.Config, error) {
	viper.SetConfigFile("./config/config.yaml")

	if err := viper.ReadInConfig(); err != nil {
		log.Fatalf("Error readin config, %s", err)
		return nil, err
	}

	var conf config.Config
	if err := viper.Unmarshal(&conf); err != nil {
		log.Fatalf("Error unmarshal config, %s", err)
		return nil, err
	}

	return &conf, nil
}
